﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>编辑角色</title>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .edit_Table tr td{ padding-top:10px; width:20px;}
        .edit_Table{ text-align:right;}
        .inputLeft{ text-align:left;}
        .show_content{ margin:0px auto;}
        label.error{ color:Red;}
    </style>

</head>
<body class="main">
    <div class="AllWebTopDiv">
        <div class="path">
            <div class="nav">
                <a href="#" id="changTop">编辑角色</a>
            </div>
        </div>
        <div class="content">
         <div class="show_content">
           <form id="edit_Role" method="post">  
            <%:Html.Hidden("OperatorId", ViewData["OperatorId"].ToString())%>
            <table class="edit_Table">
                <tr>
                    <td>
                        <label>
                            用户名：</label>
                    </td>
                    <td class = "inputLeft">
                        <%:Html.TextBox("userName")%>
                    </td>
                    <td  class="tdpadding">
                        <label>
                            用户姓名：</label>
                    </td>
                    <td class = "inputLeft">
                        <%:Html.TextBox("name")%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>
                            角色类型：</label>
                    </td>
                    <td class = "inputLeft">
                        <%:Html.DropDownList("role")%>
                    </td>
                    <td class="tdpadding">
                        <label>
                            用户性别：</label>
                    </td>
                    <td class = "inputLeft">
                         <%:Html.DropDownList("sex")%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>
                            电话号码：</label>
                    </td>
                    <td class = "inputLeft">
                        <%:Html.TextBox("phone")%>
                    </td>
                    <td class="tdpadding">
                        <label>
                            密码修改：</label>
                    </td>
                    <td class = "inputLeft">
                        <%:Html.RadioButton("radio", true, new { @id = "radio1"})%> 是
                        &nbsp;&nbsp;&nbsp;
                        <%:Html.RadioButton("radio", false, new { @id = "radio2"})%> <label id="hiddenFont">否</label>
                        
                    </td>
                </tr>
                <tr class="adminPwd" style=" display:none">
                    <td><label>新的密码：</label></td><td class = "inputLeft"><%:Html.Password("admin_NewPwd",0)%></td>
                    <td class="tdpadding">
                        <label>
                            确认密码：</label>
                    </td>
                    <td class = "inputLeft">
                       <%:Html.Password("admin_Con_Pwd", 0)%>
                    </td>
                </tr>
            
            </table>
            <br />
            <br />
            <input type="submit" value="确认" class="button2" style=" margin-left:150px;"/>
             <input type="button" value="关闭" onclick="closeWindows()" class="button2"  style=" margin-left:50px;"/>
            </form>
         </div>

        </div>
   </div>
</body>
</html>
<script type="text/javascript">

    var OperatorId = $("#OperatorId").val();
    if (OperatorId == "0") {
        $("#changTop").text("添加角色");
        $(".adminPwd").css("display", "block");
        $("#admin_NewPwd").val("");
        $("#admin_Con_Pwd").val("");
        $("#radio2").css("display", "none");
        $("#hiddenFont").css("display", "none");
    }
    
    $(document).ready(function () {

        $("#edit_Role").validate({
            rules: {
                userName: { required: true
                },
                name: {
                    required: true
                },
                phone: {
                    required: true,
                    number: true
                },
                admin_NewPwd: {
                    required: true
                },
                admin_Con_Pwd: {
                    required: true,
                    equalTo: "#admin_NewPwd"
                }
            },
            messages: {
                userName: { required: "请输入用户号"
                },
                name: { required: "请输入用户姓号"
                },
                phone: { required: "请输入电话号码",
                    number: "请输入整数"
                },
                admin_NewPwd: { required: "请输入密码" },
                admin_Con_Pwd: { required: "请再次输入密码",
                            equalTo:"两次密码不一致"
                }
            },
            errorClass: "error"

        });
    });

    //隐藏添加密码
    $(
     
      function () {
          $("#radio1").click(
            function () {
                $(".adminPwd").css("display", "block");
                $("#admin_NewPwd").val("");
                $("#admin_Con_Pwd").val("");
            }
          );

          $("#radio2").click(
            function () {
                $("#admin_NewPwd").val("0");
                $("#admin_Con_Pwd").val("0");
                $(".adminPwd").css("display", "none");
            }
          );
      }
    );

    //关闭窗口
    function closeWindows() {
        var i = parent.layer.getFrameIndex();
        parent.layer.close(i);
    }
</script>